<template>
  <el-card 
    class="metric-card" 
    shadow="hover"
    :style="{ backgroundColor: bgColor }"
  >
    <div class="metric-content">
      <div class="title">{{ title }}</div>
      <div class="value">{{ formattedValue }}</div>
    </div>
  </el-card>
</template>

<script>
export default {
  props: {
    title: String,
    value: [Number, String],
    unit: String,
    bgColor: {
      type: String,
      default: '#fff' // 默认白色背景，适配浅色主题
    }
  },
  computed: {
    formattedValue() {
      return this.unit ? `${this.value} ${this.unit}` : this.value;
    }
  }
};
</script>

<style scoped>
.metric-card {
  border-radius: 8px;
  border: 1px solid #ebeef5;
  transition: all 0.3s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.metric-content {
  padding: 20px;
  text-align: center;
}

.title {
  font-size: 14px;
  color: #606266;
  margin-bottom: 8px;
  font-weight: 500;
}

.value {
  font-size: 24px;
  font-weight: bold;
  color: #1f2d3d;
  letter-spacing: 0.5px;
}
</style>